﻿@{
    ViewBag.Title = "Detail";
    Layout = "~/Views/Shared/LayoutWiki.cshtml";
}

@Html.Hidden("routeDataId",@ViewContext.RouteData.Values["id"])
<style type="text/css">
    #option-Wiki li {
        float:right;
        list-style-type:none;
    }
    #option-Wiki li a {
        display: block;
        text-decoration: none;
        margin: 0;
        padding: 4px 10px 4px 10px;
        color: maroon;
    }
</style>
<div id="option-Wiki">
    <li><a href="javascript:ClickDelete();">Delete</a></li>
    <li><a href="javascript:ClickLinks();">Edit</a></li>
</div>
<div id="detail-Wiki">
    <h1><span data-bind="text: subject"></span></h1>
    <div data-bind="html: body"></div>
</div>
    
<script type="text/javascript">
    var id = $('#routeDataId').val();
    function ClickLinks() {
        window.location.href = '/Wiki/Edit/'+id;
    }
    function ClickDelete() {
        var answer = confirm("Do you want to delete this wiki");
        if (answer) {
            var wikiData = {
                Id: id
            };
            $.ajax({
                type: "POST",
                url: "/Wiki/Delete",
                data: ko.toJSON(wikiData),
                contentType: "application/json",
                success: function () {
                    window.location.href = '/Wiki/Home';
                },
                error: function () {
                    alert("Failed");
                }
            });
        } 
    }
</script>


